package cc.linker.steplink.crm.merchanth5.service;

import cc.linker.steplink.crm.merchanth5.dao.CourseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

@Service
public class CourseService {

    @Autowired
    private CourseDao courseDao;

    public List<Map<String, Object>> myColumns(Map<String, Object> params) {
        List<Map<String, Object>> result = courseDao.myColumns(params);
        result.forEach(x -> {
            Integer num = courseDao.getNumByCourseId(x.get("columnId").toString());
            if (x.get("columnStatus").equals(1)) {
                // 更新中
                x.put("columnInfo", "已更新" + num + "期");
            }
            if (x.get("columnStatus").equals(2)) {
                // 已完结
                x.put("columnInfo", "已完结，共" + num + "期");
            }
        });
        return result;
    }

    public List<Map<String, Object>> myContent(Map<String, Object> params) {
        List<Map<String, Object>> result = courseDao.myContent(params);
        return result;
    }
}
